Calcifer Calcifer 2 Calcifer 3 Calcifer 4
Linux

监控 句柄

2019/03/31 13:27 6303 次阅读 王梓
打赏
✸ ✸ ✸

示例:点击 -> 性能监控

/proc/sys/fs/file-nr  每列分别代表:

已分配文件句柄的数目     已使用文件句柄的数目      文件句柄的最大数目    

[root@wangzi go]# cat /proc/sys/fs/file-nr
1280	0	98406

python监控代码:

#!/usr/bin/env python
# coding=utf-8
# author: brownwang
# mail: 277215243@qq.com
# datetime:2019/3/31 1:03 PM
# web: https://www.bthlt.com

def fd_use():
    free=0
    used=0
    total=0
    with open('/proc/sys/fs/file-nr','r') as file:
        for line in file.readlines():
            used=int(line.split()[0])
            total=int(line.split()[2])
    free=total-used
    insert_sql="""insert into `monitor_fd_use` (`used`,`free`,`flow_time`) values ({0},{1},'{2}')""".format(used,free,now_zero)
    cursorUpdate(insert_sql,[])
✸ ✸ ✸

📜 版权声明

本文作者:王梓 | 原文链接:https://www.bthlt.com/note/262-������ ������

出处:葫芦的运维日志 | 转载请注明出处并保留原文链接

📜 留言板

留言提交后需管理员审核通过才会显示